<template lang="pug">
  kalix-dialog.user-add(title='添加' bizKey="HotlistsCourse" ref="kalixBizDialog" v-bind:formModel.sync="formModel" v-bind:targetURL="targetURL" v-bind:submitAfter="submitAfter")
    div.el-form(slot="dialogFormSlot")
      el-form-item(label="课程名称" prop="cname" v-bind:label-width="labelWidth" v-bind:rules="rules.cname")
        kalix-select(v-model="formModel.cname" v-bind:requestUrl="courseURL"  placeholder="请选择课程名称"
        v-bind:paramObj="menuParam" v-bind:defaultSelect="true" v-on:selectChange="selectChange")
      el-form-item(label="标识" prop="identify" v-bind:label-width="labelWidth" v-bind:rules="rules.identify")
        el-input(v-model="formModel.identify")
</template>

<script type="text/ecmascript-6">
  import {HotlistsCourseURL, CourseURL} from '../../config.toml'
  import EventBus from '../../../../../components/corelib/common/eventbus'
  import FormModel from './model'

  export default {
    name: 'HotlistsCourseAdd',
    data() {
      return {
        courseURL: CourseURL,
        formModel: Object.assign({}, FormModel),
        labelWidth: '170px',
        rules: {
          cname: [{required: true, message: '请选择课程名称', trigger: 'change'}]
        },
        targetURL: HotlistsCourseURL,
        menuParam: undefined,
        options: []
      }
    },
    methods: {
      submitAfter() {
        console.log('+++++++++++++++++++')
        this.$nextTick(() => {
          EventBus.$emit('mess')
        })
      },
      init(dialogOption) {
        console.log('---------dialogOption------------', dialogOption)
      },
      selectChange(item) {
        this.formModel.cname = item.name
        console.log('--------------item.name------------', item.name)
      }
    }
  }
</script>

<style scoped lang="stylus" type="text/stylus">
  .el-form
    width 70%
    margin auto
    .short
      width 38%
      display inline-block
      height 40px
    .el-input
      width 70%
    .radio
      margin-left 20px
      .el-radio
        color: #3465cb
        font-weight: bold
        font-size: 14px

</style>
